<!DOCTYPE html>
<html lang="en">

<head>
    <style>
        .box {
            display: flex;
            justify-content: center;
            flex-flow: column;
            text-align: center;
        }

        p {
            margin-top: 10px;
        }

        input {
            padding-left: 5px;
        }

        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div class="box">
        <p><input type="text" value="北京市"></p>
        <p><input type="text" value="昌平区"></p>
        <p><button>传参</button></p>
    </div>
</body>
<script>
    var btn = document.getElementsByTagName('button')[0]
    var inp = document.getElementsByTagName('input')
    // console.log(inp);

    var add = function (a, b) {
        alert(a.value);
        alert(b.value)
    }
    btn.onclick = function () {
        add(inp[0], inp[1])
    }

</script>

</html>